Skip to content

Conversation

esoteric-ephemera
Copy link
Collaborator

Depends on emmet-core #1253, which adds a top-level structure field to PropertyDoc

On model_dump, the structure field should be excluded, and should not appear in the JSON schema. This adds parsing of the exclude attr of a model field in api_sanitize

@esoteric-ephemera
Copy link
Collaborator Author

esoteric-ephemera commented Sep 15, 2025

Think I may have gotten the FowardRef resolution working with this. Queries like:

MPRester().materials.phonon.search(material_ids=['mp-149'])

should correctly return pydantic documents now

The alternate solution would be ensuring emmet has no forward references, but that will require a redeploy

Copy link
Member

@tschaume tschaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @esoteric-ephemera! As this does not seem to break backward-compatibility, I'm ok with merging and releasing a new version to take care of the phonon issue. Unfortunately, the test for PhononRester still fails - same on my local machine. I ran the tests against the adkaplan-tls branch in this repo since secrets (in this case API keys) are not forwarded to forks.

@esoteric-ephemera
Copy link
Collaborator Author

esoteric-ephemera commented Sep 16, 2025

Thanks @tschaume, the issue was not importing external locals() when a field annotated as a ForwardRef was not requested. That should be fixed now, the tests pass locally and in my fork's CI

Also there's an undocumented pydantic kwarg that makes it cleaner to include external locals in a model. Making use of that now

Copy link
Member

@tschaume tschaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look good. Gtg!

@tschaume tschaume merged commit 6376bb6 into materialsproject:main Sep 16, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants